﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CommunicationLib.Model
{
    public struct  DataPackage
    {
        public int NeedLength { get; set; }
        //发送字节数据
        public byte[] SendBuffer { get; set; }
        //接收字节数据
        public byte[] ReceiveBuffer { get; set; }
        //指令编号
        public long CommandId { get; set; }
        //发送时间
        public DateTime SendTime { get; set; }
        //接收时间
        public DateTime ReceiveTime { get; set; }
        //创建时间
        public DateTime CreateTime { get; set; }
        //结束时间
        public DateTime EndTime { get; set; }
        //发送次数
        public int SendTimes { get; set; }
        //发送字节数据的字符串形式
        public string SendBufferToString
        {
            get
            {
                if(SendBuffer != null)//修正这里的判断条件
                {
                    return BitConverter.ToString(SendBuffer);
                }
                else
                {
                    return string.Empty;
                }
            } 
            
        }

        //接收字节数据的字符串形式
        public string ReceiveBufferToString
        {
            get
            {
                if (ReceiveBuffer != null) 
                {
                    return BitConverter.ToString(ReceiveBuffer);
                }
                else
                {
                    return string.Empty;
                }
            }

        }
    }
}
